using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: daiduong19051986@gmail.com 
	/// <summary>
	
    public class LOOKUPInfo
    {
		#region Local Variable
		public enum Field
		{
			DTB,
			Code,
			Category,
			Description,
			Description1,
			Lookup,
			Status
		}
		private String _DTB;
		private String _Code;
		private String _Category;
		private String _Description;
		private String _Description1;
		private String _Lookup;
		private String _Status;
		
		public String DTB{	get{ return _DTB;} set{_DTB = value;} }
		public String Code{	get{ return _Code;} set{_Code = value;} }
		public String Category{	get{ return _Category;} set{_Category = value;} }
		public String Description{	get{ return _Description;} set{_Description = value;} }
		public String Description1{	get{ return _Description1;} set{_Description1 = value;} }
		public String Lookup{	get{ return _Lookup;} set{_Lookup = value;} }
		public String Status{	get{ return _Status;} set{_Status = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public LOOKUPInfo()
		{
			_DTB = "";
			_Code = "";
			_Category = "";
			_Description = "";
			_Description1 = "";
			_Lookup = "";
			_Status = "";
		}
		public LOOKUPInfo(
		String DTB,
		String Code,
		String Category,
		String Description,
		String Description1,
		String Lookup,
		String Status
		)
		{
			_DTB = DTB;
			_Code = Code;
			_Category = Category;
			_Description = Description;
			_Description1 = Description1;
			_Lookup = Lookup;
			_Status = Status;
		}
		public LOOKUPInfo(DataRow dr)
		{
			if (dr != null)
			{
				_DTB = dr[Field.DTB.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DTB.ToString()]);
				_Code = dr[Field.Code.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Code.ToString()]);
				_Category = dr[Field.Category.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Category.ToString()]);
				_Description = dr[Field.Description.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Description.ToString()]);
				_Description1 = dr[Field.Description1.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Description1.ToString()]);
				_Lookup = dr[Field.Lookup.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Lookup.ToString()]);
				_Status = dr[Field.Status.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Status.ToString()]);
			}
		}
		public LOOKUPInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_DTB = dr[Field.DTB.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DTB.ToString()]);
				_Code = dr[Field.Code.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Code.ToString()]);
				_Category = dr[Field.Category.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Category.ToString()]);
				_Description = dr[Field.Description.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Description.ToString()]);
				_Description1 = dr[Field.Description1.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Description1.ToString()]);
				_Lookup = dr[Field.Lookup.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Lookup.ToString()]);
				_Status = dr[Field.Status.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Status.ToString()]);
			}
		}
		public LOOKUPInfo(LOOKUPInfo objEntr)
		{			
			_DTB = objEntr.DTB;			
			_Code = objEntr.Code;			
			_Category = objEntr.Category;			
			_Description = objEntr.Description;			
			_Description1 = objEntr.Description1;			
			_Lookup = objEntr.Lookup;			
			_Status = objEntr.Status;			
		}
        #endregion Constructor

        #region InitTable
        public static DataTable ToDataTable()
        {
            DataTable dt = new DataTable("Lookup");
            dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.DTB.ToString(), typeof(String)),
				new DataColumn(Field.Code.ToString(), typeof(String)),
				new DataColumn(Field.Category.ToString(), typeof(String)),
				new DataColumn(Field.Description.ToString(), typeof(String)),
				new DataColumn(Field.Description1.ToString(), typeof(String)),
				new DataColumn(Field.Lookup.ToString(), typeof(String)),
				new DataColumn(Field.Status.ToString(), typeof(String))
			});
            dt.Columns[Field.Category.ToString()].ExtendedProperties.Add("lookup", "CAT");

            return dt;
        }
        
        public DataRow ToDataRow(DataTable dt)
        {
            DataRow row = dt.NewRow();
            row[Field.DTB.ToString()] = _DTB;
            row[Field.Code.ToString()] = _Code;
            row[Field.Category.ToString()] = _Category;
            row[Field.Description.ToString()] = _Description;
            row[Field.Description1.ToString()] = _Description1;
            row[Field.Lookup.ToString()] = _Lookup;
            row[Field.Status.ToString()] = _Status;
            return row;
        }
        #endregion InitTable
    }
}
